/**
 * @version Create on 2012-11-13
 * @author Yinzi Chen
 */

public class Pow {

	public double getPow(double x, int n) {
		if (n == 0)
			return 1;
		double t = getPow(x, n >> 1);
		return t * t * (n % 2 == 1 ? x : 1.0);
	}

	public double pow(double x, int n) {
		if (n >= 0)
			return getPow(x, n);
		return 1 / (getPow(x, -(n + 1)) * x);
	}

	public static void main(String[] args) {
		Pow a = new Pow();
		System.out.println(a.pow(2, -1));
	}

}
